<?php
// +----------------------------------------------------------------------
// | QSCMS
// +----------------------------------------------------------------------
// | Copyright (c)  2025 https://www.qqss.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed QSCMS is not free software, commercial use must purchase official license from official website to avoid unnecessary legal disputes.
// +----------------------------------------------------------------------
// | Author: Contract 990504246@qq.com
// +----------------------------------------------------------------------

namespace app\adminapi\controller\user;

use app\adminapi\controller\Base;
use app\service\user\StatisticsService;

class Statistics extends Base
{
    protected $statisticsService;

    public function __construct()
    {
        parent::__construct();
        $this->statisticsService = new StatisticsService();
    }

    /**
     * Member statistics overview
     */
    public function overview()
    {
        $data = $this->statisticsService->getOverview();
        $this->success('', $data);
    }

    /**
     * Member growth trend
     */
    public function growthTrend()
    {
        $days = inputs('days/d', 30);
        $data = $this->statisticsService->getGrowthTrend($days);
        $this->success('', $data);
    }

    /**
     * Member consumption ranking
     */
    public function consumptionRanking()
    {
        $limit = inputs('limit/d', 10);
        $data  = $this->statisticsService->getConsumptionRanking($limit);
        $this->success('', $data);
    }

    /**
     * Member activity analysis
     */
    public function activityAnalysis()
    {
        $data = $this->statisticsService->getActivityAnalysis();
        $this->success('', $data);
    }
}